package itheima01;

import java.io.*;

/**
 * @author xxx
 * @date 2020/12/23 2:56
 * @description
 */
public class Test {
    public static void main(String[] args) throws IOException {
     //创建文件字节输入输出流，复制文件内容，并计算文件的复制耗时时常

        long time=System.currentTimeMillis();
        FileOutputStream fileOutputStream=new FileOutputStream("day12/from/f1.flv");
        FileInputStream fileInputStream=new FileInputStream("day12/dest/f2.flv");

        sendTime(fileOutputStream,fileInputStream);
        long time1=System.currentTimeMillis();

        System.out.println("耗时:"+(time1-time));
    }
        public static  void  sendTime(FileOutputStream fileOutputStream, FileInputStream fileInputStream) throws IOException {
            BufferedOutputStream  bufferedOutputStream=new BufferedOutputStream(fileOutputStream);
            BufferedInputStream bufferedInputStream=new BufferedInputStream(fileInputStream);

            byte[]bytes=new byte[1];
            int a=0;

            while ((a=bufferedInputStream.read(bytes))!=-1){
              bufferedOutputStream.write(bytes,0,a);
            }
    bufferedInputStream.close();
    bufferedOutputStream.close();
    }
}